import java.util.*;

/**
 * @author Administrator
 */
public class Main2 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        int cuteCount = 0;
        Queue<Integer> deque = new ArrayDeque<>();

        for (int right = 0; right < n; right++) {
            while (!deque.isEmpty() && a[deque.peek()] < a[right]) {
                deque.poll();
            }
            deque.offer(right);
            if (a[deque.peek()] >= right - deque.peek() + 1) {
                cuteCount++;
            }
            while (right - deque.peek() + 1 > 1) {
                deque.poll();
            }
        }
        System.out.println(cuteCount);
    }
}